﻿/*****************************************介绍*****************************************
 * 作者：User
 * 创建时间：2025-05-19 11:16:39
 * 功能：所有弹窗的基类
**************************************************************************************/

using DG.Tweening;
using Game.Framework;
using UnityEngine;
using UnityEngine.UI;

public abstract class PopupPanel : BasePanel
{
    protected virtual void OnEnable()
    {
        OpenEff();
    }

    public override void Hide(bool isDestroy = false)
    {
        CloseEff();
    }

    protected virtual void OpenEff()
    {
        transform.GetComponent<Image>().color = new Color32(0, 0, 0, 100);
        transform.GetComponent<Image>().DOFade(0.82f, .35f);
        transform.DOScale(Vector3.one * 1.1f, .1f).OnComplete(() => transform.DOScale(Vector3.one * 1f, .1f));
    }

    protected virtual void CloseEff(bool isOnDestroy = false)
    {
        transform.DOScale(0, .1f).OnComplete(() =>
        {
            if (isOnDestroy)
                Destroy(gameObject);
            else
            {
                gameObject.SetActive(false);
                transform.localScale = Vector3.one;
            }
        });
    }
}